<?php
$params = [];
$configFiles = [
    '/../../common/config/params.php',
    '/../../common/config/params-local.php',
    '/params.php',
    '/params-local.php',
];
foreach ($configFiles as $file) {
    if (file_exists(__DIR__ . $file)) {
        $tmp = require __DIR__ . $file;
        $params = yii\helpers\ArrayHelper::merge($params, $tmp);
    }
}
$main = [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [
        'permission' => [
            'class' => 'common\modules\permission\Module',
        ],
        // 'admin' => [
        //     'class' => 'mdm\admin\Module',
        //     'layout' => 'left-menu',//yii2-admin的导航菜单
        // ],
    ],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '8IjS88ZdTpXyqad1w8GmOVwjP2iHaPvZ',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'loginUrl' => null,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'admin',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => false,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'assetManager' => [
            'linkAssets' => true,
        ],
        // 'authManager' => [
        //     'class' => 'yii\rbac\DbManager', // 使用数据库管理配置文件
        // ]
    ],
    // 'as access' =>  [
    //     'class' => 'mdm\admin\components\AccessControl',
    //     'allowActions' => [
    //         'site/*',//允许访问的节点，可自行添加
    //         'login/*',//允许访问的节点，可自行添加
    //         'permission/*',//允许所有人访问admin节点及其子节点
    //     ]
    // ],
    'params' => $params,
];

return $main;